using UnityEngine;

public class FuelApplying : MonoBehaviour
{
	public float FuelPlus = 100f;

	public float MinDistance = 2f;

	private void Start()
	{
		CarControl[] array = (CarControl[])UnityEngine.Object.FindObjectsOfType(typeof(CarControl));
		float num = MinDistance;
		int num2 = -1;
		for (int i = 0; i < array.Length; i++)
		{
			if (array[i] != null)
			{
				float num3 = Vector3.Distance(base.transform.position, array[i].transform.localPosition);
				if (num3 < num)
				{
					num = num3;
					num2 = i;
				}
			}
		}
		if (array.Length > num2 && array[num2] != null)
		{
			array[num2].SendMessage("ApplyFuel", FuelPlus, SendMessageOptions.DontRequireReceiver);
		}
		UnityEngine.Object.Destroy(base.gameObject);
	}
}
